package com.jair.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.jair.manage.pojo.ItemDesc;
import com.jair.web.bean.Item;
import com.jair.web.service.ItemService;

/**
 * @Description 
 * @FullName com.jair.web.controller.ItemController 
 * @Author Jair_Huang
 * @Create 2017年6月2日 下午5:12:14   
 */
@RequestMapping("item")
@Controller
public class ItemController {
    @Autowired
    private ItemService itemSerice;

    @RequestMapping(value = "{itemId}", method = RequestMethod.GET)
    public ModelAndView showItemDetail(@PathVariable("itemId") Long itemId) {
        ModelAndView mv = new ModelAndView("item");

        //基本数据
        Item item = this.itemSerice.queryItemById(itemId);
        mv.addObject("item", item);

        //描述
        ItemDesc itemDesc = this.itemSerice.queryItemDescByItemId(itemId);
        mv.addObject("itemDesc", itemDesc);

        //规格参数
        String itemParamHtml = this.itemSerice.queryItemParamByItemId(itemId);
        mv.addObject("itemParam", itemParamHtml);

        return mv;
    }
}
